package io.daocloud.prometheustestdemo.config;

import io.daocloud.prometheustestdemo.interceptor.RateLimitInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * Web配置类
 */
@Configuration
public class WebConfig implements WebMvcConfigurer {
    
    @Autowired
    private RateLimitInterceptor rateLimitInterceptor;
    
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 注册限流拦截器，拦截所有请求
        registry.addInterceptor(rateLimitInterceptor)
                .addPathPatterns("/**")
                // 排除actuator端点，避免影响健康检查和指标采集
                .excludePathPatterns("/actuator/**");
    }
} 